import { autoLogin } from '@/service/api/user';
import Message from 'tdesign-miniprogram/message/index';

App({
    async onLaunch() {
        try {
            const token = wx.getStorageSync('token');
            if (!token) {
                return;
            }
            // 通过token获取用户数据
            await autoLogin(token);
            wx.reLaunch({
                url: '/pages/index/index'
            });
        } catch (err) {
            Message.error({
                content: err.message,
                offset: [60, 32],
                duration: 2000
            });
            wx.reLaunch({
                url: '/pages/login/login'
            });
        }
    }
});
